﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
using LogWare.Messages;
using LogWare.Properties;

namespace LogWare.ViewModel {
	public class OptionsViewModel : ViewModelBase {
		private string _destinationFolder;
		[Display(ResourceType = typeof(Resources))]
		public string DestinationFolder {
			get { return _destinationFolder; }
			set { 
				_destinationFolder = value;
				RaisePropertyChanged("DestinationFolder");
			}
		}

		private string _companyName;
		[DisplayName("Όνομα Εταιρείας")]
		public string CompanyName {
			get { return _companyName; }
			set {
				_companyName = value;
				RaisePropertyChanged("CompanyName");
			}
		}

		private string _companyTaxCode;
		[DisplayName(@"Α.Φ.Μ.")]
		public string CompanyTaxCode {
			get { return _companyTaxCode; }
			set {
				_companyTaxCode = value;
				RaisePropertyChanged("CompanyTaxCode");
			}
		}

		private string _companyTaxOffice;

		[DisplayName("Δ.Ο.Υ.")]
		public string CompanyTaxOffice {
			get { return _companyTaxOffice; }
			set {
				_companyTaxOffice = value;
				RaisePropertyChanged("CompanyTaxOffice");
			}
		}

		private string _companyAddress;

		[DisplayName(@"Διεύθυνση")]
		public string CompanyAddress {
			get { return _companyAddress; }
			set {
				_companyAddress = value;
				RaisePropertyChanged("CompanyAddress");
			}
		}

		private string _companyZip;

		[DisplayName(@"Τ.Κ.")]
		public string CompanyZip {
			get { return _companyZip; }
			set {
				_companyZip = value;
				RaisePropertyChanged("CompanyZip");
			}
		}

		private string _companyCity;

		[DisplayName(@"Πόλη")]
		public string CompanyCity {
			get { return _companyCity; }
			set {
				_companyCity = value;
				RaisePropertyChanged("CompanyCity");
			}
		}

		private string _companyTelephone;

		[DisplayName(@"Τηλέφωνο")]
		public string CompanyTelephone {
			get { return _companyTelephone; }
			set {
				_companyTelephone = value;
				RaisePropertyChanged("CompanyTelephone");
			}
		}

		private void InitializeProperties() {
			DestinationFolder = Settings.Default.OutputDirectory;
			CompanyName = Settings.Default.CompanyName;
			CompanyAddress = Settings.Default.CompanyAddress;
			CompanyCity = Settings.Default.CompanyCity;
			CompanyTaxCode = Settings.Default.CompanyTaxCode;
			CompanyTaxOffice = Settings.Default.CompanyTaxOffice;
			CompanyTelephone = Settings.Default.CompanyPhone;
			CompanyZip = Settings.Default.CompanyZip;
		}

		public OptionsViewModel() {
			InitializeProperties();
			DestinationPathBrowseCommand = new RelayCommand(() =>
				Messenger.Default.Send(new ChildViewMessage<string>(result => {
					if(result.UserAction==MessageBoxResult.OK) {
						DestinationFolder = result.UserData;
					}
			})));
		}

		public RelayCommand DestinationPathBrowseCommand { get; set; }

	}
}
